import '../ol/ol.css';
import Map from '../ol/Map';
import OSM from '../ol/source/OSM';
import TileLayer from '../ol/layer/Tile';
import View from '../ol/View';
import {
    DragRotateAndZoom,
    defaults as defaultInteractions,
} from '../ol/interaction';

var tian_di_tu_road_layer = new ol.layer.Tile({
    title: "天地图路网",
    source: new ol.source.XYZ({
        url: "http://t4.tianditu.com/DataServer?T=vec_w&x={x}&y={y}&l={z}&tk=42dca576db031641be0524ee977ddd04"
    })
});
//加载天地图--注记图层
var tian_di_tu_annotation = new ol.layer.Tile({
    title: "天地图文字标注",
    source: new ol.source.XYZ({
        url: 'http://t3.tianditu.com/DataServer?T=cva_w&x={x}&y={y}&l={z}&tk=42dca576db031641be0524ee977ddd04'
    })
});
//这个是本地配置的GeoServer服务器发布的WMS服务地图
var wmsSource = new ol.layer.Tile({
    source: new ol.source.TileWMS({
        url: 'http://192.168.9.123:8080/geoserver/testNew1/wms',
        params: { 'LAYERS': 'testNew1:function_layer', 'singleTile': true }

    })
});

var map = new Map({
    interactions: defaultInteractions().extend([new DragRotateAndZoom()]),
    layers: [
        new TileLayer({
            //tian_di_tu_road_layer,
            //tian_di_tu_annotation,
            source: new OSM(),
        })],
    target: 'map',
    view: new View({
        center: ol.proj.fromLonLat([107.41, 37.82]),
        zoom: 5,
        maxZoom: 18,
        minZoom: 5
    }),
});